<?php
namespace App\Admin\Controllers\Stat;

use App\Http\Controllers\Controller;
use App\Model\Stat\StatInviteInfo;
use App\Util\ComUtil;
use Encore\Admin\Controllers\ModelForm;
use Encore\Admin\Grid;
use Encore\Admin\Layout\Content;
use App\Model\Stat\StatOcpcOppo;
class  StatOcpcOppoController extends Controller
{
    use ModelForm;

    public function index()
    {
        $content = new Content();
        $content->header('统计oppo推广信息');
        $content->body($this->grid());
        return $content;
    }

    protected function grid()
    {
        $grid = new Grid(new StatOcpcOppo());
        $grid->model()->orderBy('day', 'desc');
        $grid->day('日期');
        $grid->register_user('新增人数');
        $grid->reg_recharge_user('当日新增并充值人数');
//        $grid->reg_recharge_num('新增充值次数');
//        $grid->reg_recharge_money('新增充值金额')->display(function ($money) {
//            return round($money/100,2);
//        });
//        $grid->recharge_user('新增充值人数');
//        $grid->recharge_money('新增充值金额')->display(function ($rechargeMoney){
//            return round($rechargeMoney/100,2);
//        });
//        $grid->recharge_num('当日充值次数');
        $grid->package_name('包名')->display(function ($packageName){
            return StatOcpcOppo::PKG[$packageName];
        });

//        $grid->disableExport();
        $grid->disableRowSelector();
        $grid->disableActions();
        $grid->disableCreateButton();
        $grid->filter(function ($filter) {
            $filter->expand();
            $filter->disableIdFilter();
            $filter->column(1 / 3, function ($filter) {
                $filter->between('day', '日期')->date();
            });
            $filter->column(1 / 3, function ($filter) {
                $filter->equal('package_name', '包名')->select(StatOcpcOppo::PKG);
            });
        });
        $grid->actions(function (Grid\Displayers\Actions $actions) {
            $actions->disableDelete();
            $actions->disableEdit();
            $actions->disableView();
        });
        return $grid;
    }
}
